package com.suzus.five;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConfirmCallback;
import com.rabbitmq.client.Consumer;
import com.rabbitmq.client.DeliverCallback;
import com.suzus.four.ConfirmMessage;
import com.suzus.utils.RabbitMqUtils;

import java.nio.charset.StandardCharsets;
import java.util.concurrent.ConcurrentNavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;

public class ReceiveLogs01 {

    public static final String EXCHANGE_NAME="logs";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();
        channel.exchangeDeclare(EXCHANGE_NAME,"fanout");
        String queue = channel.queueDeclare().getQueue();
        channel.queueBind(queue,EXCHANGE_NAME,"");
        System.out.println("waiting for information");

        DeliverCallback deliverCallback = (ConsumerTag,message)->{
            System.out.println(new String(message.getBody(), StandardCharsets.UTF_8));
        };

        channel.basicConsume(queue,true,deliverCallback,consumerTag->{});
    }
}
